package com.hzgj.bcl.soa.config;

import com.hzgj.bcl.soa.rpc.retry.RetryPolicy;

import java.util.Objects;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import static com.hzgj.bcl.soa.util.Constants.DEFAULT_CLUSTER_AVAILABLE_CHECK;
import static com.hzgj.bcl.soa.util.Constants.DEFAULT_CLUSTER_FAILOVER;
import static com.hzgj.bcl.soa.util.Constants.DEFAULT_PROTOCOL;
import static com.hzgj.bcl.soa.util.Constants.DEFAULT_REGISTRY;

/**
 * Created by dell on 2015/3/25.
 */
@Setter
@Getter
@ToString
public class ReferenceAttr extends ClientConfig {

    protected String cluster = DEFAULT_CLUSTER_FAILOVER;
    protected boolean check = DEFAULT_CLUSTER_AVAILABLE_CHECK;
    protected String id;
    protected String service;
    protected String version;
    protected String group;
    protected boolean async = false;
    protected String protocol = DEFAULT_PROTOCOL;
    protected RetryPolicy retryPolicy;
    protected String consumer;
    protected boolean register = DEFAULT_REGISTRY;
    //针对客户端注册
    protected String host;
    protected String domain;
    /**
     * 逗号分割的直连地址ip:port,ip:port
     */
    protected String url;
    protected String pool;

    public String getService() {
        return service;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ReferenceAttr that = (ReferenceAttr) o;
        return Objects.equals(service, that.service);
    }

    @Override
    public int hashCode() {
        return Objects.hash(service);
    }
}
